<?php include("header.inc.php") ?>
<?php include("navigation.inc.php")?>       
<?php include("left.inc.php")?>     
<!-- Giong Trang Thanh Tich -->
<div id="mainContent" class="grid_7">
 	<div class="grid_7 tieudetrang">
    	<p>THÔNG TIN GIÁO VIÊN</p>
    </div>
    <?php 
$display = 10;
        if (isset($_GET['page']) && (int)$_GET['page']) {
 	           $page = $_GET['page'];	
        } else {                   
    	       $sql = "SELECT COUNT(idthongtingiaovien) FROM thongtingiaovien WHERE status = 1";
               $query = mysql_query($sql) or die("Error query count ".mysql_error($conn));
               $rows = mysql_fetch_array($query);
               $record = $rows[0];
	           if ($record > $display) {
    	             $page = ceil($record/$display);	
               } else {
                     $page = 1;	
               }                
        $start = (isset($_GET['start']) && (int)$_GET['start'])?$_GET['start']:0;			
		$sql = "SELECT  * FROM thongtingiaovien WHERE STATUS = 1 ORDER BY thoigian DESC LIMIT $start,$display";
		$query = mysql_query($sql) or die("Can't query thongtingiaovien");
		while ($row = mysql_fetch_array($query))
		{
			
	?>
    <div class="grid_7 khungtin">
    	<div class="anhtin">
        <img src="img/thongtingiaovien/<?php echo $row['anhpreview'] ?>" alt="thong tin giao vien"/>
        </div>
        <div class="noidungtin">
        	<div class="tieudetin">
			<a href = "giaovienchitiet.php?id=<?php echo $row['idthongtingiaovien'];?>"> <?php echo substr($row['tieude'],0,100)?> </a>                   
            </div>
            <div class="thoigiantin">
				<p>(<?php echo ($time = date('d-m-Y G:i:s',strtotime($row['thoigian'])));?>)</p>                   
            </div>
            <div class="tomtattin">
            	<p><?php echo $row['tomtat'] ?></p>
            </div>
        </div>
    </div>    
    <div class="grid_7 xemchitiettin">
		<a href = "giaovienchitiet.php?id=<?php echo $row['idthongtingiaovien'];?>">Xem Chi Tiết >> </a>                   
    </div>       
    <?php 
		}
		}
	?>
    
        <div class="pagelist">
        	 <ul>
        <?php						
					if($page > 1) {
						$next = $start + $display;
						$previous = $start - $display;
						$current = ($start/$display) + 1;				
						if ($current != 1) {
							echo "<li><a href='giaovien.php?start=$previous'>Quay Lại</a></li>";	
						} 
						for ($i=1;$i<=$page;$i++){
							if($i != $current) {
								echo "<li><a href='giaovien.php?start=".($display*($i-1))."'>$i</a></li>";	
							} else {
								echo "<li class='current'>$i</li>";		
							}
						}
						if ($current != $page){
							echo "<li><a href='giaovien.php?start=$next'>Tiếp</a></li>";	
						}
					}
		?>
	         </ul>
    	</div>                              
</div>
     
<?php include("right.inc.php")?>  
<?php include("footer.inc.php")?>  

